def amount(init_amount=0):
    def atm(num, in_money=True):
        # 关键字 nonlocal
        nonlocal init_amount
        if in_money:
            init_amount += num
            print(f"存入：{num}，余额：{init_amount}")
        else:
            init_amount -= num
            print(f"取出：{num}，余额：{init_amount}")

    return atm


fn = amount()
fn(100)
fn(100)
fn(100, in_money=False)
